﻿package mortal.component
{
    import com.mui.manager.*;
    import flash.display.*;
    import flash.text.*;
    import mortal.common.net.*;

    public class BitmapLabel extends Bitmap
    {
        private var _textField:TextField;
        private var _toolTipData:Object;
        private var _htmlText:String;
        private var _bitmapData:BitmapData;
        private var _styleName:String;
        private var _isStyleChange:Boolean = false;

        public function BitmapLabel(param1:BitmapData = null, param2:String = "auto", param3:Boolean = false)
        {
            super(param1, param2, param3);
            this.createChildren();
            return;
        }// end function

        public function get textField() : TextField
        {
            return this._textField;
        }// end function

        public function set textField(param1:TextField) : void
        {
            this._textField = param1;
            return;
        }// end function

        public function get text() : String
        {
            return this._textField.text;
        }// end function

        public function set text(param1:String) : void
        {
            if (this._textField.text != param1)
            {
                this._textField.text = param1;
                this._htmlText = param1;
                CallLater.addCallBack(this.updateDisplay);
            }
            return;
        }// end function

        public function get htmlText() : String
        {
            return this._htmlText;
        }// end function

        public function set htmlText(param1:String) : void
        {
            this._htmlText = param1;
            this._textField.htmlText = this._htmlText;
            CallLater.addCallBack(this.updateDisplay);
            return;
        }// end function

        public function get wordWrap() : Boolean
        {
            return this._textField.wordWrap;
        }// end function

        public function set wordWrap(param1:Boolean) : void
        {
            this._textField.wordWrap = param1;
            return;
        }// end function

        public function get enabled() : Boolean
        {
            return this._textField.mouseEnabled;
        }// end function

        public function set enabled(param1:Boolean) : void
        {
            this._textField.mouseEnabled = param1;
            return;
        }// end function

        public function get autoSize() : String
        {
            return this._textField.autoSize;
        }// end function

        public function set autoSize(param1:String) : void
        {
            this._textField.autoSize = param1;
            return;
        }// end function

        public function get selectable() : Boolean
        {
            return this._textField.selectable;
        }// end function

        public function set selectable(param1:Boolean) : void
        {
            this._textField.selectable = param1;
            return;
        }// end function

        public function get toolTipData()
        {
            return this._toolTipData;
        }// end function

        public function set toolTipData(param1) : void
        {
            if (param1 == null || param1 == "")
            {
                ToolTipsManager.unregister(this);
            }
            else
            {
                ToolTipsManager.register(this);
            }
            this._toolTipData = param1;
            return;
        }// end function

        public function move(param1:Number, param2:Number) : void
        {
            this.x = param1;
            this.y = param2;
            return;
        }// end function

        protected function createChildren() : void
        {
            this._textField = new TextField();
            this._textField.selectable = false;
            return;
        }// end function

        public function get styleName() : String
        {
            return this._styleName;
        }// end function

        public function set styleName(param1:String) : void
        {
            if (this._styleName != param1)
            {
                this._styleName = param1;
                this._isStyleChange = true;
            }
            return;
        }// end function

        override public function set filters(param1:Array) : void
        {
            this._textField.filters = param1;
            CallLater.addCallBack(this.updateDisplay);
            return;
        }// end function

        public function get defaultTextFormat() : TextFormat
        {
            return this._textField.defaultTextFormat;
        }// end function

        public function set defaultTextFormat(param1:TextFormat) : void
        {
            this._textField.defaultTextFormat = param1;
            return;
        }// end function

        public function get textWidth() : int
        {
            return this._textField.textWidth;
        }// end function

        public function get textHeight() : int
        {
            return this._textField.textHeight;
        }// end function

        public function setStyle(param1:String, param2) : void
        {
            if (param1 == "textFormat")
            {
                this._textField.defaultTextFormat = param2 as TextFormat;
            }
            return;
        }// end function

        public function getStyle(param1:String)
        {
            if (param1 == "textFormat")
            {
                return this._textField.defaultTextFormat;
            }
            return null;
        }// end function

        public function setSize(param1:Number, param2:Number) : void
        {
            this.width = param1;
            this.height = param2;
            return;
        }// end function

        override public function get width() : Number
        {
            return this._textField.width;
        }// end function

        override public function set width(param1:Number) : void
        {
            if (this.textField)
            {
                this.textField.width = param1;
                CallLater.addCallBack(this.updateDisplay);
            }
            return;
        }// end function

        override public function get height() : Number
        {
            return this._textField.height;
        }// end function

        override public function set height(param1:Number) : void
        {
            if (this.textField)
            {
                this.textField.height = param1;
                CallLater.addCallBack(this.updateDisplay);
            }
            return;
        }// end function

        private function updateDisplay() : void
        {
            if (this._bitmapData)
            {
                this._bitmapData.dispose();
            }
            this._bitmapData = new BitmapData(this._textField.width, this._textField.height, true, 0);
            this._bitmapData.draw(this._textField);
            this.bitmapData = this._bitmapData;
            return;
        }// end function

    }
}
